// RequireJS Bootstrap File

/**
 *  require.config
 *
 *  This function will take an object of options and configure our RequireJS
 *  environment for us.
 *
 *  In this case we have simply defined the base URL (relative to the root
 *  of the website) and some additional paths that map to resources that
 *  we would like to define.
 *
 *  i.e., to define a resource for the Google Maps API, we will define a
 *  friendly name for it (google-maps), and set the value of this entry
 *  to the the URI of that resource (//maps.googleapis.com/maps/api/js?sensor=false).
 *
 *  For more information on the funny URL we used for google-maps, check out
 *  this _fantastic_ article written by Paul Irish (one of the giants in
 *  webdevelopment):
 *
 *  http://www.paulirish.com/2010/the-protocol-relative-url/
 */
require.config({
	
	// Define the base location of all js modules for this application.
	baseUrl : 'public/js/',

	// For each file to be included in the application, define a path.
	// The left-hand-side is the desired name of the file, i.e., module, as it
	// is referenced by requires.js
	//
	// The right-hand-side is the relative path and filename, omitting the .js.
	paths : {
		'jquery' : 'vendor/jquery/jquery-2.0.3',
		'jquery.ui' : 'vendor/jquery-ui/jquery-ui.min',
	        'autocomplete':'vendor/jquery-ui/jquery-ui.autocomplete',
		'utilities' : 'components/utilities',
		'gui' : 'components/gui',
		'admissions' : 'components/admissions',
		'layers' : 'components/layers',
		'census' : 'components/census',
		'usmap' : 'components/usmap'
	},
	
	// The jquery.ui third-party library is not written in module
	// form and must be shimmed into the collection of modules using
	// this requires.js trick.
	shim : {
		'jquery.ui': {
			exports : '$',
			deps : ['jquery']
		}
	}
});

/**
 *
 *  require
 *
 *  This is the meat and bones of our Require bootstrap. Here we will define
 *  each of the modules, libraries, and other JS files that we will use in
 *  our project.
 *
 *  This process is similar to including files in a C file.
 *
 *  Notice that to define an import statement, we can simply point to the
 *  file relative to our baseUrl (defined in require.config above).
 *
 */
require(['jquery', 'utilities', 'gui', 'admissions', 'layers', 'census', 'usmap','jquery.ui'], function($, utilities, gui, admissions, layers, census, usmap) {

	// Note that the order of definition is VERY important. 

	// 'jquery' is first, that is the name of our module as we defined above.
	// In the function, $ is first.  That is how we will want to access this
	// third party library in our code.

	// The closure above accepts arguments <= the number of dependencies we have
	// listed, otherwise those arguments don't mean anything.
	var $document = $(document);
	$document.ready(function() {
		usmap.initialize();
	});
	//document
});
//require()
